package org.yihang.common.hibernate;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;

@SuppressWarnings("serial")
public class HibernateAwareObjectMapper extends ObjectMapper{

	public HibernateAwareObjectMapper() {
		super();
		Hibernate5Module module = new Hibernate5Module() 
					//.enable(Hibernate5Module.Feature.FORCE_LAZY_LOADING)
					.enable(Hibernate5Module.Feature.REPLACE_PERSISTENT_COLLECTIONS);
		registerModule(module);
		this.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS);
		this.setSerializationInclusion(Include.NON_NULL);
	}

}
